/*-
 * Copyright (c) 2009-2010 David Forsythe.
 * See LICENSE file for license details.
 */

#include <archive.h>
#include <archive_entry.h>

#include "freebsd_plist.h"
#include "freebsd_database_directorydb.h"
#include "freebsd_repository_ftp.h"

/* Probably pointless. */

struct _pkg_element {
        struct pkg_property *plnode;
};

#define pkg_conflict _pkg_element
#define pkg_dependency _pkg_element
#define pkg_file _pkg_element
#define pkg_exec _pkg_element

struct pkg *pkg_freebsd_create(void);

struct pkg_database *pkg_freebsd_database_create(void);

struct pkg_repository *pkg_freebsd_repository_create(void);

int pkg_freebsd_set_name(struct pkg *, const char *);

const char *pkg_freebsd_get_name(struct pkg *);

int pkg_freebsd_set_origin(struct pkg *, const char *);

const char *pkg_freebsd_get_origin(struct pkg *);

const char *pkg_freebsd_get_comment(struct pkg *);

const char *pkg_freebsd_get_format_revision(struct pkg *);

const char *pkg_freebsd_get_description(struct pkg *);

const char *pkg_freebsd_get_display(struct pkg *);

int pkg_freebsd_get_preserve(struct pkg *);

/* Rquired by. */

const char *pkg_freebsd_get_next_required_by(struct pkg *);

void pkg_freebsd_required_by_rewind(struct pkg *);

void pkg_freebsd_remove_required_by(struct pkg *p, const char *);

/* Files. */

int pkg_freebsd_get_next_file(struct pkg *, struct pkg_file *);

int pkg_freebsd_file_create(struct pkg *, struct pkg_file *);

int pkg_freebsd_file_set_pathname(struct pkg_file *, const char *);

const char *pkg_freebsd_file_get_pathname(struct pkg_file *);

int pkg_freebsd_file_set_prefix(struct pkg_file *, const char *);

const char *pkg_freebsd_file_get_prefix(struct pkg_file *);

int pkg_freebsd_file_set_hash(struct pkg_file *, const char *);

const char *pkg_freebsd_file_get_hash(struct pkg_file *);

int pkg_freebsd_file_get_ignored(struct pkg_file *);

/* Dependencies. */

int pkg_freebsd_get_next_dependency(struct pkg *, struct pkg_dependency *);

int pkg_freebsd_dependency_create(struct pkg *, struct pkg_dependency *);

const char *pkg_freebsd_dependency_get_name(struct pkg_dependency *);

const char *pkg_freebsd_dependency_get_origin(struct pkg_dependency *);

/* Conflicts. */

int pkg_freebsd_get_next_conflict(struct pkg *, struct pkg_conflict *);

int pkg_freebsd_conflict_create(struct pkg *, struct pkg_conflict *);

int pkg_freebsd_conflict_set_expression(struct pkg_conflict *, const char *);

const char *pkg_freebsd_conflict_get_expression(struct pkg_conflict *);

/* Exec/Unexec */

int pkg_freebsd_get_next_exec(struct pkg *, struct pkg_exec *);

int pkg_freebsd_get_next_unexec(struct pkg *, struct pkg_exec *);

const char *pkg_freebsd_exec_get_command(struct pkg_exec *);

/* Scripts. */

int pkg_freebsd_register_install_script(struct pkg *, const char *);

int pkg_freebsd_register_post_install_script(struct pkg *, const char *);

int pkg_freebsd_register_deinstall_script(struct pkg *, const char *);

int pkg_freebsd_register_post_deinstall_script(struct pkg *, const char *);

int pkg_freebsd_register_script(struct pkg *, const char *, const char *,
        const char *);

int pkg_freebsd_run_install_script(struct pkg *);

int pkg_freebsd_run_post_install_script(struct pkg *);

int pkg_freebsd_run_deinstall_script(struct pkg *);

int pkg_freebsd_run_post_deinstall_script(struct pkg *);

const char *pkg_freebsd_get_install_script_path(struct pkg *);

const char *pkg_freebsd_get_post_install_script_path(struct pkg *);

const char *pkg_freebsd_get_deinstall_script_path(struct pkg *);

const char *pkg_freebsd_get_post_deinstall_script_path(struct pkg *);

const char *pkg_freebsd_get_require_script_path(struct pkg *);

/* Execute. */
char *pkg_freebsd_run_command(const char *, ...);

/* Extract. */
int pkg_freebsd_extract(struct pkg *, struct archive *, struct archive_entry *);
